#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char *str;

    char origin[] = "redis";

    /* 最初的内存分配 */
    str = (char *)malloc(sizeof(origin) / sizeof(char));
    strcpy(str, "redis");
    printf("%d\n", sizeof(origin) / sizeof(char));
    printf("String = %s,  Address = %p\n", str, str);

    /* 重新分配内存 */
    char ped[] = ".io";
    str = (char *)realloc(str, sizeof(origin) + sizeof(ped) / sizeof(char));
    strcat(str, ped);
    printf("%d\n", sizeof(origin) + sizeof(ped) / sizeof(char));
    printf("String = %s,  Address = %p\n", str, str);

    free(str);

    return (0);
}